package com.open.basic.enums;


import com.open.basic.constant.SystemConst;


/**
 * @author system
 * @Date 2023/12/3 13:38
 * @description 系统状态枚举
 */
public enum StatusEnum {
    /**
     * 1 正常
     */
    USE(SystemConst.STATUS_USE, "正常"),
    /**
     * 2 禁用
     */
    DISABLE(SystemConst.STATUS_DISABLE, "禁用"),
    /**
     * 3 删除
     */
    DELETE(SystemConst.STATUS_DELETE, "删除"),
    /**
     * 4 锁定
     */
    LOCK(SystemConst.STATUS_LOCK, "锁定");

    private int value;

    private String desc;

    StatusEnum(int value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public int getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    public static StatusEnum getEnum(int value) {
        for (StatusEnum statusEnum : StatusEnum.values()) {
            if (statusEnum.getValue() == value) {
                return statusEnum;
            }
        }
        return null;
    }

    public static String getDesc(Integer value) {
        if (value == null) {
            return null;
        }
        for (StatusEnum statusEnum : StatusEnum.values()) {
            if (statusEnum.getValue() == value) {
                return statusEnum.getDesc();
            }
        }
        return null;
    }

    public static String getDesc(int value) {
        for (StatusEnum statusEnum : StatusEnum.values()) {
            if (statusEnum.getValue() == value) {
                return statusEnum.getDesc();
            }
        }
        return null;
    }

    public static boolean exist(int value) {
        for (StatusEnum statusEnum : StatusEnum.values()) {
            if (statusEnum.getValue() == value) {
                return true;
            }
        }
        return false;
    }
}
